Function QueryExists(strKey As String)

    QueryExists = False
    Dim query As WorkbookQuery
    For Each query In ActiveWorkbook.Queries
        If query.Name = strKey Then
            QueryExists = True
            Exit Function
        End If
    Next
    
End Function